<?php

class Funcionario_model extends CI_Model
{



	
	private $id;

	
	private $cpf;

	
	private $nome;

	
	private $cargo;

	
	private $cargo_casemg;

	
	private $ultima_alteracao;

	
	private $usuario;



	function __construct() 	
	{ 
		// Call the Model constructor 
		parent::__construct(); 
	} 

	function inserir() 	
	{ 
		 
	}

	function alterar() 	
	{ 
		 
	}


	function get_id() 	
	{ 
		if (isset($this->id))
		{
			return $this->id;
		}
	} 




	function get_cpf() 	
	{ 
		if (isset($this->cpf))
		{
			return $this->cpf;
		}
	} 




	function get_nome() 	
	{ 
		if (isset($this->nome))
		{
			return $this->nome;
		}
	} 




	function get_cargo() 	
	{ 
		if (isset($this->cargo))
		{
			return $this->cargo;
		}
	} 




	function get_cargo_casemg() 	
	{ 
		if (isset($this->cargo_casemg))
		{
			return $this->cargo_casemg;
		}
	} 




	function get_ultima_alteracao() 	
	{ 
		if (isset($this->ultima_alteracao))
		{
			return $this->ultima_alteracao;
		}
	} 




	function get_usuario() 	
	{ 
		if (isset($this->usuario))
		{
			return $this->usuario;
		}
	} 

	function buscaPorCPF($cpf)
	{
	  $this->db->select('*');
	  $this->db->from('funcionario');
	  $this->db->where("cpf = '{$cpf}'");
	  $query = $this->db->get();
	  return $query;
	} 

	function buscaPorId($id)
	{
	  $this->db->select('*');
	  $this->db->from('funcionario');
	  $this->db->where("id = '{$id}'");
	  $query = $this->db->get();
	  $b = $query->result_array();
	  return $b[0]['nome'];
	}
	
	function montaSelect($default = 0)
	{
	  $this->db->select('*');
	  $this->db->from('funcionario');
	  $this->db->order_by('nome');
	  $query = $this->db->get();
	  $select = "<select name = 'funcionario' id = 'funcionario'>
	    <option value = '0'>SELECIONE</option>";
	  foreach($query->result() as $row)
	  {
	    $select .= "<option value = '{$row->id}'";
	    $select .= ($default == $row->id)? "selected":"";
	    $select .= ">$row->nome</option>";
	  }
	  $select .= "</select>";
	  return $select;
	}


}

?>
